var t = getApp();

Page({
    data: {
        id: "",
        receive_point: "0.00",
        used_point: "0.00",
        validity_point: 0,
        total_page: 0,
        dataList: [],
        isLoadMore: !0,
        activeName: 0,
        statuNum: 0
    },
    onLoad: function(t) {
        t.activity_id && this.setData({
            id: t.activity_id
        }), this._getData(null);
    },
    onReady: function() {},
    onShow: function() {
        var t = wx.getStorageSync("yz_basic_info").theme_color;
        this.setData({
            subjectColor: t
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    _getData: function(a) {
        var i = this;
        i.setData({
            statuNum: a || "",
            page: 1
        });
        var e = {};
        e = null === a ? {
            activity_id: i.data.id ? Number(i.data.id) : "",
            page_id: 1
        } : {
            activity_id: i.data.id ? Number(i.data.id) : "",
            page_id: 1,
            status: a
        };
        var o = t.getNetAddresss("plugin.point-activity.Frontend.Modules.Activity.Controllers.activity-receive-records.index");
        t._postNetWork({
            url: o,
            showToastIn: !1,
            data: e,
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    var e = a.data;
                    i.setData({
                        receive_point: e.receive_point,
                        used_point: e.used_point,
                        validity_point: e.validity_point,
                        total_page: e.records.last_page ? e.records.last_page : 0
                    }), i.data.total_page || i.setData({
                        total_page: 0
                    }), i.setData({
                        dataList: e.records.data
                    });
                } else wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    _getMoreData: function() {
        var a = this;
        if (!(this.data.page >= this.data.total_page)) {
            this.setData({
                page: this.data.page + 1
            });
            var i = t.getNetAddresss("plugin.point-activity.Frontend.Modules.Activity.Controllers.activity-receive-records.index");
            t._postNetWork({
                url: i,
                showToastIn: !1,
                data: {
                    activity_id: a.data.id,
                    page_id: a.data.page,
                    status: a.data.statuNum
                },
                success: function(t) {
                    var i = t.data;
                    if (1 == i.result) {
                        var e = i.data.records.data;
                        a.setData({
                            dataList: a.data.dataList.concat(e)
                        });
                    } else a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {}
            });
        }
    },
    handleClick: function(t) {
        var a = t.detail.index;
        this.setData({
            dataList: [],
            isLoadMore: !0
        }), 0 === Number(a) ? this._getData(null) : this._getData(Number(a) - 1);
    }
});